package cn.edu.nchu.fragmentdemo.entity;

import cn.edu.nchu.fragmentdemo.bean.Route;
import cn.edu.nchu.fragmentdemo.bean.WayPoint;
import cn.edu.nchu.fragmentdemo.entity.MyBasicEntity;
import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.overlay.Overlay;

import java.io.Serializable;
import java.util.ArrayList;

/**
 * @author Wendy
 * @time 2020/1/4
 * @Email ${EMAIL}
 */
public class MyRouteEntity extends MyBasicEntity implements Serializable {
    String id;
    String tag;
    Overlay overlay;
    Route route;
    String popMenu;
    ArrayList<WayPoint> wayPoints;
    ArrayList<GeoPoint> geoPoints;

    public MyRouteEntity() {
        wayPoints = new ArrayList<>();
        geoPoints = new ArrayList<>();
    }

    public void setGeoPoints(ArrayList<GeoPoint> geoPoints) {
        this.geoPoints = geoPoints;
        for (GeoPoint geoPoint : geoPoints) {
            WayPoint wayPoint = new WayPoint();
            wayPoint.setWayPointLongitude((double) geoPoint.getLongitude());
            wayPoint.setWayPointLatitude((double) geoPoint.getLatitude());
            wayPoints.add(wayPoint);
        }
    }

    public ArrayList<GeoPoint> getGeoPoints() {
        return geoPoints;
    }

    public void addToWayPoints(WayPoint thisWayPoint) {
        this.wayPoints.add(thisWayPoint);
    }

    @Override
    public void setId(String id) {
        this.id = id;
        this.route.setUk(id);
    }

    @Override
    public String getId() {
        return id;
    }

    @Override
    public Overlay getOverlay() {
        return overlay;
    }

    @Override
    public void setOverlay(Overlay overlay) {
        this.overlay = overlay;
    }

    @Override
    public void setDbTag(String dbTag) {
        super.setDbTag(tag);
    }

    @Override
    public String getDbTag() {
        return super.getDbTag();
    }

    public Route getEntity() {
        return route;
    }

    public void setEntity(Route route) {
        this.route = route;
    }

    @Override
    public String getPopMenuType() {
        return null;
    }

    @Override
    public void setPopMenuType(String popMenuType) {

    }

    public void setTag(String dbTag) {
        this.tag = dbTag;
    }
}
